<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<header class="navbar navbar-expand-lg navbar-light bg-white fixed-top border-bottom">
    <div class="container">
        <a class="navbar-brand d-flex align-items-center" href="${pageContext.request.contextPath}/user/home">
            <img src="${pageContext.request.contextPath}/static/images/3.png" alt="Logo" height="40" class="me-2">
            <span>教育新闻网</span>
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav mx-auto">
                <li class="nav-item mx-3">
                    <a class="nav-link" href="${pageContext.request.contextPath}/user/home">首页</a>
                </li>
            
                <li class="nav-item dropdown mx-3">
                    <a class="nav-link" href="#" id="navNews">
                        新闻实事
                    </a>
                    <ul class="dropdown-menu fade-up" aria-labelledby="navNews">
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/news?category=校园新闻">校园新闻</a></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/news?category=事件新闻">事件新闻</a></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/user/news?category=活动新闻">活动新闻</a></li>
                    </ul>
                </li>
                <li class="nav-item mx-3">
                    <a class="nav-link" href="${pageContext.request.contextPath}/user/campus-style">校园风采</a>
                </li>
                <li class="nav-item mx-3">
                    <a class="nav-link" href="${pageContext.request.contextPath}/user/forum">校园论坛</a>
                </li>
                <li class="nav-item mx-3">
                    <a class="nav-link" href="${pageContext.request.contextPath}/user/consult">心理咨询</a>
                </li>
                <li class="nav-item mx-3">
                    <a class="nav-link" href="${pageContext.request.contextPath}/user/career">就业指导</a>
                </li>
                <li class="nav-item mx-3">
                    <a class="nav-link" href="${pageContext.request.contextPath}/user/feedback">
                       反馈建议
                    </a>
                </li>
                <li class="nav-item mx-3">
                    <a class="nav-link" href="${pageContext.request.contextPath}/user/contact">
                       联系我们
                    </a>
                </li>
            </ul>
            <div class="d-flex">
                <c:choose>
                    <c:when test="${empty sessionScope.user}">
                        <a href="${pageContext.request.contextPath}/user/login.jsp" class="btn btn-link text-dark me-2">登录</a>
                        <a href="${pageContext.request.contextPath}/user/register.jsp" class="btn btn-primary">注册</a>
                    </c:when>
                    <c:otherwise>
                        <span class="navbar-text me-3">欢迎，${sessionScope.user.username}</span>
                        <a href="${pageContext.request.contextPath}/user/logout" class="btn btn-outline-primary">退出</a>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
    </div>
    <style>
        .navbar {
            box-shadow: 0 2px 4px rgba(0,0,0,.08);
        }
        .navbar .nav-link {
            color: #333 !important;
            font-size: 16px;
            position: relative;
            padding: 0.5rem 0;
        }
        .navbar .nav-link::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 2px;
            background: #0d6efd;
            transition: width 0.3s;
        }
        .navbar .nav-link:hover::after,
        .navbar .nav-link.active::after {
            width: 100%;
        }
        .navbar .dropdown {
            position: relative;
        }
        .navbar .dropdown-menu {
            display: block;
            visibility: hidden;
            opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s;
            margin-top: 0;
            border: none;
            box-shadow: 0 2px 5px rgba(0,0,0,.1);
            border-radius: 4px;
        }
        .navbar .dropdown:hover .dropdown-menu {
            visibility: visible;
            opacity: 1;
            transform: translateY(0);
        }
        .navbar .dropdown-item {
            padding: 8px 20px;
            color: #333;
            transition: all 0.3s;
        }
        .navbar .dropdown-item:hover {
            background-color: #f8f9fa;
            color: #0d6efd;
            padding-left: 25px;
        }
        .btn-link {
            text-decoration: none;
        }
        .btn-link:hover {
            text-decoration: underline;
        }
    </style>
</header>
<div style="margin-top: 76px;"></div> <!-- 为固定导航栏留出空间 --> 